import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import Layout from "@/layout/index.vue";
/**
 * 固定路由
 */
export const constantRoutes = [
  {
    path: "/login",
    component: () => import("@/views/login.vue"),
  },
  {
    path: "",
    component: Layout,
    redirect: "index",
    children: [
      {
        path: "index",
        component: () => import("@/views/index.vue"),
        name: "index",
      },
    ],
  },
];

export const userRoutes = [
  {
    path: "/system",
    redirect: "system",
    name: "系统管理",
    component: Layout,
    children: [
      {
        path: "/user",
        component: () => import("@/views/system/user.vue"),
        name: "用户管理",
      },
      {
        path: "/student",
        component: () => import("@/views/system/student.vue"),
        name: "学生管理",
      },
      {
        path: "/teacher",
        component: () => import("@/views/system/teacher.vue"),
        name: "教师管理",
      },
      {
        path: "/class",
        component: () => import("@/views/system/class.vue"),
        name: "班级管理",
      },
      {
        path: "/classroom",
        component: () => import("@/views/system/classroom.vue"),
        name: "教室管理",
      },
    ],
  },
];

const routes: Array<RouteRecordRaw> = [...constantRoutes, ...userRoutes];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
